subroutine read_initial_condition(lunit)
  use param
  use mat_param,only:half_a0
  use data_param,only:init_exist
  use data_param,only:infn
  implicit none

  interface
     integer function str2label(str)
       character :: str*(*)
     end function str2label
  end interface

  integer,intent(in) :: lunit

  integer :: nunit,count_line,len_str,asci_code
  character(len=len_linebuf) :: eatline
  character(len=len_wordbuf),dimension(max_n_word) :: eatword

  integer :: i,n
  integer :: lid,ierr
  real(dbl) :: px,py,pz,dx,dy,dz
  logical :: removed

  if (.not.init_exist) return

  nunit=1

  open(unit=nunit,file=infn,status='old',err=104)

  count_line=0
  n=0

  do
     ! make it clear
     ! to treat the case when the words for direction are blank
     eatline=""
     do i=1,max_n_word
        eatword(i)=""
     end do

     ! read a line
     read(nunit,'(a)',end=100,err=101) eatline
     count_line=count_line+1

     ! skip the comments or blank lines
     len_str=len_trim(eatline)
     if (len_str.eq.0) cycle
     eatline=adjustl(eatline)
     asci_code=ichar(eatline(1:1))
     if (asci_code.eq.ccode) cycle
     read(eatline(1:len_str),*,end=102) &
          (eatword(i),i=1,max_n_word)
102  continue

     ! read the label of the object
     lid=str2label(eatword(2))
     if (lid.eq.0) then
        call terminal_msg1(eatline)
        call abnormal_stop("read_initial_condition",&
             "Unrecognized label is found in the initial condition.")
     end if

     n=n+1

     ! read the position
     read(eatword(3),*) pz
     read(eatword(4),*) px
     read(eatword(5),*) py

     ! read the direction of alignment
     read(eatword(6),*,err=103,iostat=ierr) dz
     read(eatword(7),*,err=103,iostat=ierr) dx
     read(eatword(8),*,err=103,iostat=ierr) dy
103  continue

     ! if the direction is not specified,
     ! set dir as 1.
     if (ierr.ne.0) then
        dx=0
        dy=0
        dz=0
     else
        dx=dx
        dy=dy
        dz=dz
     end if

     call boundary_check(px,py,pz,removed)

     if (removed) cycle

     call create_object(lid,px,py,pz,ierr,dx,dy,dz)

  end do

104 continue
  call abnormal_stop("read_initial_condition",&
       "Error occurs during opening the file for initial condition.")

101 continue
  call abnormal_stop("read_initial_condition",&
       "Error occurs during reading the file for initial condition.")

100 continue
  close(nunit)

  return

end subroutine read_initial_condition
